package programmercarl.贪心.C6;

class Solution {
    public int maxProfit(int[] prices) {
        int maxProfit = 0;
        int[] profits = new int[prices.length-1];
        for (int i = 0; i < prices.length-1; i++) {
            profits[i] = prices[i+1] - prices[i];
        }
        for (int i = 0; i < prices.length-1; i++) {
            if (profits[i] > 0) {
                maxProfit+=profits[i];
            }
        }

        return maxProfit;
    }
}